package com.university.mentalhealthplatform.studentV3.dto;

import com.university.mentalhealthplatform.appModels.Teacher;
import com.university.mentalhealthplatform.global.rbac.dto.normal.RoleDTO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Date;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

@Getter
@Setter
@NoArgsConstructor
public class TeacherDTOV3 extends UserDTOV3 {
    private String department;
    private String college;
    private String address;
    private Date birthDate;
    private String name;
    private String number;
    private String gender;

    // 全参构造方法
    public TeacherDTOV3(UUID id, String username, boolean status, String department, String college, String address,
                        Date birthDate, String name, String number, String gender, Set<RoleDTO> roles) {
        super(id, username, status,roles);  // 调用父类 UserDTOV3 的构造方法
        this.department = department;
        this.college = college;
        this.address = address;
        this.birthDate = birthDate;
        this.name = name;
        this.number = number;
        this.gender = gender;
    }

    public static TeacherDTOV3 convertToDTO(Teacher teacher) {
        Set<RoleDTO> roleDTOs = teacher.getRoles().stream()
                .map(RoleDTO::convertToDTO)
                .collect(Collectors.toSet());

        return new TeacherDTOV3(
                teacher.getId(),
                teacher.getUsername(),
                teacher.isStatus(),
                teacher.getDepartment(),
                teacher.getCollege(),
                teacher.getAddress(),
                teacher.getBirthDate(),
                teacher.getName(),
                teacher.getNumber(),
                teacher.getGender(),
                roleDTOs
        );
    }
}
